To minimise implementation complexity, the bit allocation scheme in the MPEG-2 Test Model-5 (TM-5) makes use of a complexity measure of a present picture of a certain type (I, P, or B) to estimate the target bit allocation of the next picture of the same type. After a picture of a certain type (I, P, or B) is encoded, the respective “global complexity measure” (Xi, Xp, or Xb) is updated as:Xi=SiQi  (1)Xp=SpQp  (2)Xb=SbQb  (3)where Si, Sp, Sb are the number of bits generated by encoding this picture and Qi, Qp, and Qb are the average quantization parameters computed by averaging the actual quantization values used during the encoding of all the macroblocks, including skipped macroblocks.
The target number of bits (Ti, Tp, or Tb) for the next picture in a group of pictures (GOP) is computed as:Ti=max{R/(1+NpXp/XiKp+NbXb/XiKb), bit_rate/(8*picture_rate)}  (4)Tp=max{R/(Np+NbKpXb/KbXp), bit_rate/(8*picture_rate)}  (5)Tb=max{R/(Nb+NpKbXp/KpXb), bit_rate/(8*picture_rate)}  (6)where:                Kp and Kb are “universal” constants dependent on the quantization matrices;        Np and Nb are the number of P-pictures and B-pictures remaining in the current GOP in the encoding order;        R is the remaining number of bits assigned to the GOP; and R is updated after encoding a picture, as follows:R=R−Si,p,b where Si,p,b is the number of bits generated in the picture just encoded (depending on whether the picture is I, P, or B).        Before encoding the first picture in a GOP (an I-picture):R=G+R G=bit_rate*N/picture_rate        N is the number of pictures in the GOP        At the start of the sequence R=0.        
The TM-5 bit allocation method is described fully in “International Organisation for Standardisation ISO-IEC/JTCI/SC29/WG11: Coded Representation of Picture and Audio Information, Test Model 5”.
In the TM-5 bit allocation method, using the current picture complexity to estimate the next picture bit allocation gives rise to inaccuracies when a scene change occurs in the next picture.
The bit allocation method used in TM-5 to calculate the target number of bits for the next picture is based on the global complexity measure (Xi, Xp, and Xb) of the current picture, which can result in an inaccurate prediction of the target number of bits when a scene change occurs. Referring to FIG. 2, when a scene change occurs, the complexity measure, Xp1, of the next P-picture (P1) after the scene change will normally be higher.
But since the target number of bits for the P-picture after the scene change is based on the complexity measure of the P-picture before the scene change, the target bits for P1 may be inaccurately predicted. Likewise for the P-picture following P1, the target will be inaccurately predicted as being much higher due to the high complexity measure of P1 being used. The effect of this is that a degradation of picture quality in the several pictures after the scene change will propagate from the encoding error in the first P-picture. To address the problems associated with the scene change situation, an intra-encoding mode can be used to encode a picture which includes a new scene, such as described in U.S. Pat. No. 5,532,746. When a scene change is detected in a P-picture, the picture is allocated with bits corresponding to the intra-coded picture and the picture is coded in an intra-mode. In U.S. Pat. No. 5,832,121, the start of a GOP is determined by detecting a new scene in order to intra-frame code the new scene. These kinds of methods do not have a fixed number of pictures in a GOP during encoding of a sequence, and are not suitable to use for an encoder system which requires a fixed number of pictures in a GOP.
Some methods avoid picture degradation in the scene change situation by allocating more bits to encode the new scene picture. In U.S. Pat. No. 5,731,835, when a scene change occurs, extra bits are allocated to encode the picture, where the number of bits depends on 1) the distance of the P-picture that is about to be coded from the end group of pictures; 2) the number of I-mode macroblocks in the P-picture; 3) ease of coding the I-mode macroblocks in the P-picture; and 4) the number of bits presently in the video buffer verifier (VBV). In this method, the situations where multiple scene changes occur close together may require a significant number of extra bits, and as the extra number of bits is only limited by the potential of a VBV underflow occurrence, it could increase the chance of panic-mode encoding. In panic-mode encoding, only the minimum amount of data required to maintain the integrity of the bitstream is transmitted, which significantly degrades the picture encoding quality.
In U.S. Pat. No. 5,617,150, SUBGOPs are defined as sets of 2-4 frames in a GOP, and if a scene change is found in a subsequent SUBGOP, bit allocation adjustment is made to save bits in the current SUBGOP, and when a scene change is found in the current SUBGOP, extra bits are assigned to the current SUBGOP. As this method requires detection of a scene change in a subsequent SUBGOP before bits assignment, there is an undesirable encoding latency. Also, as bits are saved in the current SUBGOP so as to be used in next SUBGOP, it is only suitable for constant bit-rate applications, as using bits saved from previous pictures is not necessary in variable bit-rate applications.
When a scene change occurs, the first P-picture after the scene change will generally be difficult to encode and will need more bits because of the intra-mode coding required. B-pictures are not affected as much due to the usual bi-directional motion estimation thereof. In addition, because the error in the P-picture will propagate, it is important to minimise the degradation in quality of the first P-picture after a scene change.
It is an object of this invention that the above inaccurate bit allocation estimation problems of TM-5 are addressed by correcting the picture complexity value that is used to estimate the bit allocation for the next picture, or that it at least provides a useful alternative. This inaccuracy problem applies to the two subsequent P-pictures that follows the scene change as both of these P-pictures have inaccurate picture complexity values used for their bit allocation assignment. By adjusting the picture complexity value following the scene change detection to give a more accurate bit allocation to the two P-pictures after the scene change, this method can be used for encoder bit-rate control for both constant bit-rate and also variable bit-rate schemes. It should be noted that reducing the'bit allocation for other pictures to compensate for the increase in bit allocation for scene change is not necessary for variable bit-rate applications.
It is noted that for multiple scene changes close together, for example scene changes which occur every 2 to 3 frames, the increased target bit allocation for every scene change is not realistic in constant bit-rate applications. Also, human visual acuity is generally not able to sensibly interpret such an apparently ‘continuous’ scene change.